<?php
    class my_error {
        private $error;
    
        /*构造函数*/
        public function __construct($error) {
            $this->error = $error;
        }
        
        public function to_string() {
            $arr = array ('result'=>1,'msg'=>$this->error);
            return json_encode($arr);
        }
    }
    
    class my_retval {
        private $retval;
        private $usrdata;
    
        /*构造函数*/
        public function __construct($retval) {
            $this->retval = $retval;
        }
        
        public function add($key, $value) {
            if ($this->usrdata==null) {
                $this->usrdata = array();
            }
            $this->usrdata[$key] = $value;
        }
        
        public function to_string() {
            $arr = array ('result'=>0,'msg'=>$this->retval);
            if ($this->usrdata!=null) {
                $arr = $arr + $this->usrdata;
            }
            return json_encode($arr);
        }
    }